package com.pu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.github.pagehelper.Page;
import com.pu.dto.DishPageQueryDTO;
import com.pu.entity.Dish;
import com.pu.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @Author Yusc
 * @Date 2023/10/26 16:23
 * @Version
 * @Description 菜品数据访问层
 **/
@Mapper
public interface DishMapper extends BaseMapper<Dish> {

    /**
     * @param dishPageQueryDTO
     * @auther: Yusc
     * @date 2023/10/27 0:52
     * @Description 菜品分页查询
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * @param dish
     * @auther: Yusc
     * @date 2023/10/28 17:32
     * @Description 根据分类id查询菜品
     */
    List<Dish> list(Dish dish);

    /**
     * @param id
     * @auther: Yusc
     * @date 2023/10/28 22:47
     * @Description 根据套餐id查询菜品
     */
    @Select("select a.* from dish a left join setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getBySetmealId(Long setmealId);

    /**
     * @param map
     * @auther: Yusc
     * @date 2023/11/8 18:07
     * @Description 根据条件统计菜品数量
     */
    Integer countByMap(Map map);
}
